import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    redirect: '/bloglogin',
    component: () => import('../views/Home'),
    children: [
      {
        path: 'bloglogin',
        name: 'bloglogin',
        component: () => import('../views/Home/BlogLogin'),
      },
      {
        path: 'blogtype',
        name: 'blogtype',
        component: () => import('../views/Home/BlogType'),
      },
      {
        path: 'blogcontent',
        name: 'blogcontent',
        component: () => import('../views/Home/BlogContent'),
      },
      {
        path: 'messageboard',
        name: 'messageboard',
        component: () => import('../views/Home/MessageBoard'),
      },
    ],
  },
  { path: '*', name: '404', component: () => import('../views/404') },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  },
})

export default router
